<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>试题添加信息</title>
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
</head>
<style>
    .s-add {
        margin-left: auto;
        margin-right: auto;
        max-width: 400px;
        background: #F7F7F7;
        padding: 25px 15px 25px 10px;
        font: 12px Georgia, "Times New Roman", Times, serif;
        color: #888;
        text-shadow: 1px 1px 1px #FFF;
        border: 1px solid #E4E4E4;
    }

    .s-add h1 {
        font-size: 25px;
        padding: 0px 0px 10px 40px;
        display: block;
        border-bottom: 1px solid #E4E4E4;
        margin: -10px -15px 30px -10px;;
        color: #888;
    }

    .s-add h1 > span {
        display: block;
        font-size: 11px;
    }

    .s-add label {
        display: block;
        margin: 0px;
    }

    .s-add label > span {
        float: left;
        width: 20%;
        text-align: right;
        padding-right: 10px;
        margin-top: 10px;
        color: #888;
    }

    .s-add input[type="text"], .s-add select {
        border: 1px solid #DADADA;
        color: #888;
        height: 30px;
        margin-bottom: 16px;
        margin-right: 6px;
        margin-top: 2px;
        outline: 0 none;
        padding: 3px 3px 3px 5px;
        width: 70%;
        font-size: 12px;
        line-height: 15px;
        box-shadow: inset 0px 1px 4px #ECECEC;
    }

    .s-add select {
        -webkit-appearance: none;
        text-indent: 0.01px;
        text-overflow: '';
        width: 70%;
        height: 35px;
        line-height: 25px;
    }

    .s-add .button {
        background: #E27575;
        border: none;
        padding: 10px 25px 10px 25px;
        color: #FFF;
        box-shadow: 1px 1px 5px #B6B6B6;
        border-radius: 3px;
        text-shadow: 1px 1px 1px #9E3F3F;
        cursor: pointer;
    }

    .s-add .button:hover {
        background: #CF7A7A
    }

    .s-add input[type="radio"] {
        margin-bottom: 16px;
        margin-top: 10px;
    }
</style>
<script>
    function addexam() {
        $.ajax({
            url: '/exam/add',
            data: {
                question_id: $("#question_id").val(),
                question_subject: $("#question_subject").val(),
                question_type: $("#question_type").val(),
                question_option: $("#question_option").val(),
                question_answer: $("#question_answer").val(),
                question_level: $("#question_level").val(),
                question_direction: $("#question_direction").val()
            },
            type: 'post',
            dataType: 'json',
            success: function (data) {
                console.log(data);
                $("question_subject").val(data[0].result);
                window.location.href = "/html/tikuHtml/spreserve.html";
            }
        })
    }

    // 试题类型  难易程度 试题方向
    $(function () {
        selectAllLevel();
        selectAllType();
        selectAllDirection();
    })

    function selectAllLevel() {
        $.ajax({
            url: '/exam/findAllLevel',
            type: 'post',
            dataType: 'json',
            success: function (data) {
                console.log(data);
                let da = data[0].data;
                for (let i = 0; i < da.length; i++) {
                    $("#question_level").append('<option value="' + da[i].select_name + '">' + da[i].select_name + '</option>')
                }
            }
        })
    }

    function selectAllType() {
        $.ajax({
            url: '/exam/findAllType',
            type: 'post',
            dataType: 'json',
            success: function (data) {
                console.log(data);
                let da = data[0].data;
                for (let i = 0; i < da.length; i++) {
                    $("#question_type").append('<option value="' + da[i].select_name + '">' + da[i].select_name + '</option>')
                }
            }
        })
    }

    function selectAllDirection() {
        $.ajax({
            url: '/exam/findAllDirection',
            type: 'post',
            dataType: 'json',
            success: function (data) {
                console.log(data);
                let da = data[0].data;
                for (let i = 0; i < da.length; i++) {
                    $("#question_direction").append('<option value="' + da[i].select_name + '">' + da[i].select_name + '</option>')
                }
            }
        })
    }


</script>
<body>
<form action="" method="post" class="s-add">
    <h1>试题添加信息表</h1>
    <label>
        <span>试题题目 :</span>
        <input type="text" style="width:53%" id="question_subject">
    </label>
    <label>
        <span>试题类型 :</span>
        <select style="width:55%" id="question_type"></select>
    </label>
    <label>
        <span>试题科目 :</span>
        <input type="text" style="width:53%" id="question_option">
    </label>
    <label>
        <span></span>
        A<input type="radio" value="A">
        B<input type="radio" value="B">
        C<input type="radio" value="C">
        D<input type="radio" value="D">
    </label>
    <label>
        <span>试题答案 :</span>
        <input type="text" style="width:53%" id="question_answer">
    </label>
    <label>
        <span>难易程度 :</span>
        <select style="width:55%" id="question_level"></select>
    </label>
    <label>
        <span>试题方向 :</span>
        <select style="width:55%" id="question_direction"></select>
    </label>
    <label>
        <span>&nbsp;</span>
        <input type="button" class="button" value="保存" onclick="addexam()"/>
        <input type="reset" class="button" value="重置"/>
        <input type="button" class="button" value="返回" onclick="location.href='/html/tikuHtml/spreserve.html'"/>
    </label>
</form>
</body>
</html>